const path = require('path')
const ESLintPlugin = require('eslint-webpack-plugin')

module.exports = {
  /* 模块处理规则
    1.使用babel
  */
  entry: './src/index',
  mode: 'development',
  devtool: false,
  output: {
    filename: '[name].js',
    path: path.resolve(__dirname, 'dist')
  },
  // 添加 eslint-webpack-plugin 插件实例
  plugins: [new ESLintPlugin()],
  module: {
    rules: [
      // 2.使用ts
      {
        test: /\.ts$/,
        use: [
          {
            loader: 'babel-loader',
            options: {
              // presets: ['@babel/preset-env'],
              // 配置ts转码
              presets: ['@babel/preset-typescript']
            }
          }
        ]
      }
    ]
  },
  resolve: {
    extensions: ['.ts', '.js']
  }
}
